#!/bin/bash

source /home/shell/util.sh

if [ "$(ostype)" == "Ubuntu" ]; then
    apt -y install subversion
else
    yum -y install subversion
fi
useradd -m svn
svnadmin create /home/svn/codelovers

echo "admin=admin123" >> /home/svn/codelovers/conf/passwd
tee /home/svn/codelovers/conf/authz -a<<EOF
[/]
admin=rw
EOF

sed -i "s/# password-db = passwd/password-db = passwd/g" /home/svn/codelovers/conf/svnserve.conf
sed -i "s/# authz-db = authz/authz-db = authz/g" /home/svn/codelovers/conf/svnserve.conf
sed -i "s/# anon-access = read/anon-access = read/g" /home/svn/codelovers/conf/svnserve.conf

# 创建服务
bash /home/shell/serviced-install.sh<<EOF
2
2

svnserve
svnserve -dr /home/svn/codelovers --listen-port 9001




EOF
firewall-addport 9001


printInfo "============================SVN============================"
printInfo "svn地址：svn://${host_addr}:9001/"
printInfo "管理员账号：admin"
printInfo "管理员密码：admin123"
printInfo "系统配置：/home/svn/codelovers/conf/svnserve.conf"
printInfo "用户配置：/home/svn/codelovers/conf/passwd"
printInfo "权限配置：/home/svn/codelovers/conf/authz"
printInfo "============================SVN============================"